package cn.redsoft.turingapi.dto;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.redsoft.turingapi.common.util.Consts;
import cn.redsoft.turingapi.exception.TuringRequestException;
import cn.redsoft.turingapi.msg.BaseMsg;

/**
 * 图灵 API 请求
 * 
 * @author HuYongLiang
 *
 */
public abstract class TuringRequest {

	protected Logger log = LoggerFactory.getLogger(this.getClass());

	protected String key = Consts.TURING_API_KEY;// 必须
	protected String info;// 必须
	protected String userid = null;// 上下文必须
	protected String loc;// 非必须 北京中关村
	protected long lon;// 非必须 东经116.234632（小数点后保留6位），需要写为116234632
	protected long lat;// 非必须 北纬40.234632（小数点后保留6位），需要写为40234632

	public TuringRequest() {
	}

	public TuringRequest(String key, String info) {
		super();
		this.key = key;
		this.info = info;
	}

	public abstract String doRequest() throws Exception;

	public abstract BaseMsg getResult() throws TuringRequestException;

	public TuringRequest(String info) {
		super();
		this.info = info;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getInfo() {
		return info;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	public String getUserid() {
		return userid;
	}

	public void setUserid(String userid) {
		this.userid = userid;
	}

	public String getLoc() {
		return loc;
	}

	public void setLoc(String loc) {
		this.loc = loc;
	}

	public long getLon() {
		return lon;
	}

	public void setLon(long lon) {
		this.lon = lon;
	}

	public long getLat() {
		return lat;
	}

	public void setLat(long lat) {
		this.lat = lat;
	}

	@Override
	public String toString() {
		return "TuringRequest [key=" + key + ", info=" + info + ", userid="
				+ userid + ", loc=" + loc + ", lon=" + lon + ", lat=" + lat
				+ "]";
	}

}
